package com.spic.business.mountguard.controller;

import com.spic.business.mountguard.domain.MountGuardLeadersignin;
import com.spic.business.mountguard.service.IMountGuardLeadersigninService;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import com.spic.common.security.annotation.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * 领导上岗到位Controller
 * @author yangjie
 * @date 2021-11-01
 */
@RestController
@RequestMapping("/mountguard/leadersignin")
public class MountGuardLeadersigninController extends BaseController
{
    @Autowired
    private IMountGuardLeadersigninService mountGuardLeadersigninService;
    /**
     * 新增领导上岗到位签到
     */
    @PreAuthorize(hasPermi = "business/mountguard:leadersignin:add")
    @Log(title = "领导上岗到位签到", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MountGuardLeadersignin mountGuardLeadersignin)
    {
        return toAjax(mountGuardLeadersigninService.insertMountGuardLeadersignin(mountGuardLeadersignin));
    }

    /**
     * 查询二维码 是否过期  给我传一个uuid
     */
    @GetMapping(value = "/getQrCodeState/{key}")
    public AjaxResult getQrCodeState(@PathVariable("key")String key)
    {
        return AjaxResult.success(mountGuardLeadersigninService.selectQrCodeState(key));
    }


    @GetMapping(value = "/getSignResult")
    public  AjaxResult selectSignCount(){
        List<HashMap<String, Object>> hashMaps = mountGuardLeadersigninService.selectSignCount();
        return AjaxResult.success(hashMaps);
    }
}
